<?php 
	include("includes/connect_db.php"); 

	$aksi = $_GET['aksi'];

	switch ($aksi) {
		case '1':
			$sql = "UPDATE tb_autostart SET autostart = '0'";
			$query = mysql_query($sql);
			break;
		
		case '2':
			$sql = "UPDATE tb_autostart SET autostart = '1'";
			$query = mysql_query($sql);
			break;

		case '3':
			passthru("net start > service.log");
			$handle = fopen("service.log", "r");
			while (!feof($handle))
			{
			   $baristeks = fgets($handle);
			   if (substr_count($baristeks, 'Gammu SMSD Service (GammuSMSD)') > 0)
			   {
			     $status = 1;
			   }
			}
			fclose($handle);
			if ($status == 1) {
				echo "<div class='border'>";
					echo "<div class='service'>";
						echo "Status Service ";
						echo "<button class='status btn btn-success mati'>";
							echo "<i class='icon-white icon-off'></i>";
							echo " On";
						echo "</button>";
					echo "</div>";
				echo "</div>";
			} else if ($status == 0) {
				echo "<div class='border'>";
					echo "<div class='service'>";
						echo "Status Service ";
						echo "<button class='status btn btn-danger hidup'>";
							echo "<i class='icon-white icon-off'></i>";
							echo " Off";
						echo "</button>";
					echo "</div>";
				echo "</div>";
			}
			break;

			case '4':
				passthru('C:\Gammu\bin\gammu-smsd -k');
				break;

			case '5':
				passthru('C:\Gammu\bin\gammu-smsd -c smsdrc -s');
				break;
	}
?>